﻿<KCtl:BasePhoneApplicationPage 
    xmlns:KCtl="clr-namespace:Kiva7.Controls"
    x:Class="Kiva7.Pages.JournalEntryPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:my="clr-namespace:Kiva7.Pages" FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="696" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True" Loaded="PhoneApplicationPage_Loaded"
    ImageData="{Binding Selected.Image}">

    <Grid x:Name="LayoutRoot" Background="Transparent">
        <!--Pivot Control-->
        <KCtl:OrientedPivot x:Name="Pivot" Title="{Binding Path=L.KivaJournalEntry, Source={StaticResource L}}" IsTabStop="False">
            <controls:PivotItem Header="{Binding Path=L.Journal, Source={StaticResource L}}" x:Name="Journal">

                <Grid Margin="0,0,0,17" x:Name="JournalEntriesGrid">
                    <ScrollViewer Visibility="{Binding IsLoaded, Converter={StaticResource booleanToVisibility}}">
                        <StackPanel DataContext="{Binding Selected}" Margin="12,0,0,0">
                            <StackPanel Style="{StaticResource KivaPanelTextLargeStyle}">
                                <TextBlock Text="{Binding Subject}" Style="{StaticResource KivaTextLargeStyle}"
                           TextWrapping="Wrap"/>
                            </StackPanel>

                            <StackPanel Orientation="Horizontal" Margin="0,6,0,0" >
                                <TextBlock Text="{Binding Date, Converter={StaticResource toShortDate}}" 
                               Style="{StaticResource KivaTextAccentStyle}"/>
                                <TextBlock Text="{Binding Author}" Style="{StaticResource KivaTextAccentStyle}"/>
                            </StackPanel>

                            <KCtl:KivaImageControl x:Name="imgLender" 
                                               ImageSize="Normal" 
                                               ImageData="{Binding Image}" 
                                               Width="318" 
                                               Height="240"
                                               Margin="0,6,0,0"
                                               Visibility="{Binding Image, Converter={StaticResource objectVisibility}}"/>
                            <StackPanel Style="{StaticResource KivaDetailStyle}"
                                        Margin="0,6,0,0">
                                <KCtl:TranslationControl x:Name="journalTranslation" 
                                                 DataContext="{Binding Translation}" />
                            </StackPanel>
                            <my:MediaControl x:Name="media" DataContext="{Binding Translation}" />

                        </StackPanel>
                    </ScrollViewer>
                </Grid>

            </controls:PivotItem>

            <controls:PivotItem Header="{Binding Path=L.Comments, Source={StaticResource L}}">
                <Grid x:Name="commentsGrid">
                    <ProgressBar Visibility="{Binding IsLoaded, Converter={StaticResource booleanToNotVisibility}}" 
                     IsIndeterminate="{Binding IsLoaded, Converter={StaticResource notBooleanConverter}}" 
                     Style="{StaticResource CustomIndeterminateProgressBar}"
                     VerticalAlignment="Center" />

                    <ListBox x:Name="lbxJournalEntries" Margin="0,0,-12,0" 
              Background="{StaticResource KivaBackgroundBrush}"
             ItemsSource="{Binding Data}" 
             HorizontalContentAlignment="Stretch" 
             Visibility="{Binding IsLoaded, Converter={StaticResource booleanToVisibility}}">

                        <ListBox.ItemTemplate>

                            <DataTemplate>

                                <StackPanel Margin="0,0,0,18" Style="{StaticResource KivaListItemStyle}">

                                    <TextBlock Text="{Binding Author}" Style="{StaticResource KivaTextSmallStyle}"/>

                                    <TextBlock Text="{Binding Translation.Text, Converter={StaticResource tagStripperConverter}}" Style="{StaticResource KivaTextNormalStyle}" 
                                        TextWrapping="Wrap" Margin="10,0,0,0"/>

                                    <StackPanel Orientation="Horizontal" >
                                        <TextBlock Text="{Binding Date, Converter={StaticResource toShortDate}}" 
                               Style="{StaticResource KivaTextSmallStyle}"/>

                                        <TextBlock Text="{Binding WhereAbouts}" Style="{StaticResource KivaTextSmallStyle}"/>
                                    </StackPanel>

                                </StackPanel>

                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </Grid>
            </controls:PivotItem>
        </KCtl:OrientedPivot>
    </Grid>

    <KCtl:Bindable.ApplicationBar>
        <KCtl:BindableApplicationBar IsVisible="True" IsMenuEnabled="True" >

        </KCtl:BindableApplicationBar>
    </KCtl:Bindable.ApplicationBar>

</KCtl:BasePhoneApplicationPage>
